package com.carbon.assets.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.carbon.assets.entity.CarbonAssetAssessment;
import com.carbon.assets.mapper.CarbonAssetAssessmentMapper;
import com.carbon.assets.param.BusinessDataQueryParam;
import com.carbon.assets.param.CarbonAssetAssessmentQueryParam;
import com.carbon.assets.service.CarbonAssetAssessmentService;
import com.carbon.assets.vo.CarbonAssetAssessmentQueryVo;
import com.carbon.assets.vo.CarbonDetectionDataVo;
import com.carbon.common.api.Paging;
import com.carbon.common.service.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.Serializable;


/**
 * 服务实现类
 * 负责处理碳资产评估相关的业务逻辑
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CarbonAssetAssessmentServiceImpl extends BaseServiceImpl<CarbonAssetAssessmentMapper, CarbonAssetAssessment> implements CarbonAssetAssessmentService {

    @Resource
    private CarbonAssetAssessmentMapper carbonAssetAssessmentMapper;

    /**
     * 获取业务数据
     * 根据业务数据查询参数，返回相应的碳检测数据
     *
     * @param businessDataQueryParam 业务数据查询参数
     * @return 返回碳检测数据对象
     */
    @Override
    public CarbonDetectionDataVo getBusinessData(BusinessDataQueryParam businessDataQueryParam) {
        return carbonAssetAssessmentMapper.getBusinessData(businessDataQueryParam);
    }

    /**
     * 根据ID获取碳资产评估信息
     *
     * @param id 碳资产评估记录的唯一标识
     * @return 返回碳资产评估信息对象
     */
    @Override
    public CarbonAssetAssessmentQueryVo getCarbonAssetAssessmentById(Serializable id) {
        return carbonAssetAssessmentMapper.getCarbonAssetAssessmentById(id);
    }

    /**
     * 获取碳资产评估的分页列表
     * 根据查询参数，返回碳资产评估的分页数据
     *
     * @param param 碳资产评估查询参数
     * @return 返回分页的碳资产评估数据列表
     */
    @Override
    public Paging<CarbonAssetAssessmentQueryVo> getCarbonAssetAssessmentPageList(CarbonAssetAssessmentQueryParam param) {
        IPage<CarbonAssetAssessmentQueryVo> iPage = carbonAssetAssessmentMapper.getCarbonAssetAssessmentPageList(getPage(param),param);
        return new Paging<>(iPage);
    }

}

